//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Common
//  File name:	IQueryBuilderConditionGroup.cs
//  Developer:	Solomatov Igor
//  Created:	15.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System;
using System.Collections.Generic;
using Microsoft.SharePoint;

namespace Smart.Common.Entities
{
	/// <summary>
	/// Group of condition items
	/// </summary>
	public interface IQueryBuilderConditionGroup<TExecutorType> : IQueryBuilderItem<TExecutorType>
		where TExecutorType : class
	{
		/// <summary>
		/// Parent Group
		/// </summary>
		IQueryBuilderConditionGroup<TExecutorType> Parent { get; }


		IQueryBuilderConditionGroup<TExecutorType> Filter(string field, FilterCondition op);
		IQueryBuilderConditionGroup<TExecutorType> Filter(string field, FilterCondition op, object value);
		IQueryBuilderConditionGroup<TExecutorType> Filter(string field, FilterCondition op, object value1, object value2);

		IQueryBuilderConditionGroup<TExecutorType> Eq(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> Eq(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> Eq(string field, double value);
		IQueryBuilderConditionGroup<TExecutorType> Eq(string field, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Eq(string field, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(string field, double value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(string field, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(string field, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(string field, double value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(string field, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(string field, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(string field, double value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(string field, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(string field, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(string field, double value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(string field, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(string field, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(string field, double value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(string field, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(string field, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> In(string field, params int[] values);
		IQueryBuilderConditionGroup<TExecutorType> In(string field, params double[] values);
		IQueryBuilderConditionGroup<TExecutorType> In(string field, params bool[] values);
		IQueryBuilderConditionGroup<TExecutorType> In(string field, params string[] values);
		IQueryBuilderConditionGroup<TExecutorType> In(string field, params DateTime[] values);
		IQueryBuilderConditionGroup<TExecutorType> BeginsWith(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> Contains(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> IsNull(string field);
		IQueryBuilderConditionGroup<TExecutorType> IsNotNull(string field);
		IQueryBuilderConditionGroup<TExecutorType> Membership(string field, MembershipType membership);
		IQueryBuilderConditionGroup<TExecutorType> EqL(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> NeqL(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> Includes(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludes(string field, int value);
		IQueryBuilderConditionGroup<TExecutorType> Includes(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludes(string field, string value);
		IQueryBuilderConditionGroup<TExecutorType> EqU(string field, SPUser value);
		IQueryBuilderConditionGroup<TExecutorType> EqU(string field, int userId);
		IQueryBuilderConditionGroup<TExecutorType> NeqU(string field, SPUser value);
		IQueryBuilderConditionGroup<TExecutorType> NeqU(string field, int userId);
		IQueryBuilderConditionGroup<TExecutorType> IncludesU(string field, SPUser value);
		IQueryBuilderConditionGroup<TExecutorType> IncludesU(string field, int userId);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludesU(string field, SPUser value);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludesU(string field, int userId);
		IQueryBuilderConditionGroup<TExecutorType> EqU(string field);
		IQueryBuilderConditionGroup<TExecutorType> NeqU(string field);
		IQueryBuilderConditionGroup<TExecutorType> IncludesU(string field);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludesU(string field);

		IQueryBuilderConditionGroup<TExecutorType> DateRangesOverlap(string fieldStartDate, string fieldEndDate,
																	 string fieldRecurrenceId, DateTime value,
																	 bool includeTimeValue);

		IQueryBuilderConditionGroup<TExecutorType> DateRangesOverlap(string fieldStartDate, string fieldEndDate,
																	 string fieldRecurrenceId, DateRangesOverlapValue value);

		IQueryBuilderConditionGroup<TExecutorType> Eq(string field, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Neq(string field, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Geq(string field, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Leq(string field, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Gt(string field, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Lt(string field, DateTime value, bool includeTimeValue);


		IQueryBuilderConditionGroup<TExecutorType> Filter(Guid fieldId, FilterCondition op);
		IQueryBuilderConditionGroup<TExecutorType> Filter(Guid fieldId, FilterCondition op, object value);
		IQueryBuilderConditionGroup<TExecutorType> Filter(Guid fieldId, FilterCondition op, object value1, object value2);

		IQueryBuilderConditionGroup<TExecutorType> Eq(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> Eq(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> Eq(Guid fieldId, double value);
		IQueryBuilderConditionGroup<TExecutorType> Eq(Guid fieldId, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Eq(Guid fieldId, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(Guid fieldId, double value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(Guid fieldId, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Neq(Guid fieldId, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(Guid fieldId, double value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(Guid fieldId, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Geq(Guid fieldId, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(Guid fieldId, double value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(Guid fieldId, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Leq(Guid fieldId, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(Guid fieldId, double value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(Guid fieldId, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Gt(Guid fieldId, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(Guid fieldId, double value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(Guid fieldId, bool value);
		IQueryBuilderConditionGroup<TExecutorType> Lt(Guid fieldId, DateTime value);
		IQueryBuilderConditionGroup<TExecutorType> In(Guid fieldId, params int[] values);
		IQueryBuilderConditionGroup<TExecutorType> In(Guid fieldId, params double[] values);
		IQueryBuilderConditionGroup<TExecutorType> In(Guid fieldId, params bool[] values);
		IQueryBuilderConditionGroup<TExecutorType> In(Guid fieldId, params string[] values);
		IQueryBuilderConditionGroup<TExecutorType> In(Guid fieldId, params DateTime[] values);
		IQueryBuilderConditionGroup<TExecutorType> BeginsWith(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> Contains(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> IsNull(Guid fieldId);
		IQueryBuilderConditionGroup<TExecutorType> IsNotNull(Guid fieldId);
		IQueryBuilderConditionGroup<TExecutorType> Membership(Guid fieldId, MembershipType membership);
		IQueryBuilderConditionGroup<TExecutorType> EqL(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> NeqL(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> Includes(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludes(Guid fieldId, int value);
		IQueryBuilderConditionGroup<TExecutorType> Includes(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludes(Guid fieldId, string value);
		IQueryBuilderConditionGroup<TExecutorType> EqU(Guid fieldId, SPUser value);
		IQueryBuilderConditionGroup<TExecutorType> EqU(Guid fieldId, int userId);
		IQueryBuilderConditionGroup<TExecutorType> NeqU(Guid fieldId, SPUser value);
		IQueryBuilderConditionGroup<TExecutorType> NeqU(Guid fieldId, int userId);
		IQueryBuilderConditionGroup<TExecutorType> IncludesU(Guid fieldId, SPUser value);
		IQueryBuilderConditionGroup<TExecutorType> IncludesU(Guid fieldId, int userId);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludesU(Guid fieldId, SPUser value);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludesU(Guid fieldId, int userId);
		IQueryBuilderConditionGroup<TExecutorType> EqU(Guid fieldId);
		IQueryBuilderConditionGroup<TExecutorType> NeqU(Guid fieldId);
		IQueryBuilderConditionGroup<TExecutorType> IncludesU(Guid fieldId);
		IQueryBuilderConditionGroup<TExecutorType> NotIncludesU(Guid fieldId);

		IQueryBuilderConditionGroup<TExecutorType> DateRangesOverlap(Guid fieldIdStartDate, Guid fieldIdEndDate,
																	 Guid fieldIdRecurrenceId, DateTime value,
																	 bool includeTimeValue);

		IQueryBuilderConditionGroup<TExecutorType> DateRangesOverlap(Guid fieldIdStartDate, Guid fieldIdEndDate,
																	 Guid fieldIdRecurrenceId, DateRangesOverlapValue value);

		IQueryBuilderConditionGroup<TExecutorType> Eq(Guid fieldId, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Neq(Guid fieldId, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Geq(Guid fieldId, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Leq(Guid fieldId, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Gt(Guid fieldId, DateTime value, bool includeTimeValue);
		IQueryBuilderConditionGroup<TExecutorType> Lt(Guid fieldId, DateTime value, bool includeTimeValue);


		IQueryBuilderConditionGroup<TExecutorType> And { get; }
		IQueryBuilderConditionGroup<TExecutorType> Or { get; }
		IQueryBuilderConditionGroup<TExecutorType> End { get; }

		/// <summary>
		/// Return Cache key
		/// </summary>
		string GetCacheKey();

		bool IsDateRangesOverlapUsed { get; }

		List<IQueryBuilderItem<TExecutorType>> FindRecursive(string op);
	}
}